import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.EditText
import androidx.fragment.app.Fragment
import com.example.shenshijia.R
//import kotlinx.android.synthetic.main.fragment_add_word.*

class AddWordFragment : Fragment() {

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return inflater.inflate(R.layout.fragment_add_word, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        val addWordButton: Button = view.findViewById(R.id.add_word_button)
        val wordInput: EditText = view.findViewById(R.id.word_input)

        addWordButton.setOnClickListener {
            val wordText = wordInput.text.toString()
            if (wordText.isNotEmpty()) {
                println("Added new word: $wordText")

                // 清空输入框
                wordInput.text.clear()
                // fragmentManager?.popBackStack()
            }
        }
    }
}